#include "PixmapTextObject.h"
#include <QPainter>
#include <QPixmap>

namespace TWUtils {
namespace UI {

	QSizeF PixmapTextObject::intrinsicSize(QTextDocument*, int, const QTextFormat& format)
	{
		QPixmap icon = qVariantValue<QPixmap>(format.properties().value(DefaultIcon));
		return QSizeF(icon.size());
	}

	void PixmapTextObject::drawObject(QPainter *painter, const QRectF &rect,
					QTextDocument*, int, const QTextFormat& format)
	{
		QPixmap icon = qVariantValue<QPixmap>(format.properties().value(DefaultIcon));
		painter->drawPixmap(rect.toRect(),icon);
	}
}
}
